#include <vga.h>
#include <string.h>
#include <i386.h>
#include <syscalls.h>
#include <tipos.h>
#include <fs.h>
#include <stdio.h>

int main(void) {
	
	char *p;
	stdio_init();
	char buffer[16];
	
	FILE_DESC pp[2];
	
	p = palloc();
	
	p[0] = 'I';
	p[1] = '\0';
	
	pipe(pp);
	
	share_page(p);
	
	stdio_printf("Pagina %x\n", p);
	
	if (!fork()) {
		
		p[0] = 'H';
		p[1] = '\0';
		
		stdio_printf("Hijo (%d)\n", getpid() );
		
		write(pp[1], buffer, 1);
	}
	else {
		
		read(pp[0], buffer, 1);
		
		stdio_printf("LEIDO: (%s)\n", p);
		
		stdio_printf("Padre (%d)\n", getpid() );
		
	}
	
	stdio_wait();

	exit();

	return 0;
}
